<!DOCTYPE html>
<style>
#myframe {
  height: 35px;
  width: 100px;
}
</style>

<script src="../../resources/js-test.js"></script>
<script>

setPrintTestResultsLazily();
window.jsTestIsAsync = true;

description("Ensure hit test cache is cleared across iframes.");

function loaded() {
  document.body.insertAdjacentHTML('beforeend', '<iframe id="myframe" srcdoc="" onload="iFrameLoaded()"></iframe>');
  doHit();
}

function iFrameLoaded() {
  doHit();
  document.getElementById('myframe').contentDocument.body.insertAdjacentHTML('beforeend', '<div>AAA</div>');
  doHit();
  finishJSTest();
}

function doHit() {
  var rect = document.getElementById('myframe').getBoundingClientRect();
  internals.elementFromPoint(document, rect.left + 8, rect.top + 8, false, false);
  shouldBe("internals.hitTestCacheHits(document)", "0");
}
</script>
<body onload="loaded()" />
